USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[PlayerStatsTeamSelectByLogIdPlayerId]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.PlayerStatsTeamSelectByLogIdPlayerId
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	PlayerStatsTeam Table Select By PlayerId and LogId
-- =============================================
CREATE PROCEDURE PlayerStatsTeamSelectByLogIdPlayerId

            @LogId int,
			@PlayerId varchar(30)
	
AS
BEGIN

DECLARE @Assists int,
		@ReturnName varchar(50),
		@Kills int,
		@Deaths int,
		@Destructions int,
		@BuiltObjects int,
		@Captures int,
		@CaptureBlocks int,
		@FlagsCaptured int,
		@FlagsTouched int,
		@FlagsDefended int,
		@Ubers int,
		@Dominations int,
		@Revenges int,
		@KillDeathRatio float,
		@Backstabs int,
		@Headshots int


EXECUTE AssistsSelectCountByPlayerIdLogId @LogId, @PlayerId, @Assists OUTPUT
EXECUTE PlayerNameListSelectNameById @PlayerId, @ReturnName OUTPUT
EXECUTE KillsSelectCountByPlayerIdLogId @LogId, @PlayerId, @Kills OUTPUT
EXECUTE DeathsSelectCountByPlayerIdLogId @LogId, @PlayerId, @Deaths OUTPUT
EXECUTE DestructionsSelectCountByPlayerIdLogId @LogId, @PlayerId, @Destructions OUTPUT
EXECUTE EngineeringSelectCountByPlayerIdLogId @LogId, @PlayerId, @BuiltObjects OUTPUT
EXECUTE CaptureListSelectCountByPlayerIdLogId @LogId, @PlayerId, @Captures OUTPUT
EXECUTE CaptureBlocksSelectCountByPlayerIdLogId @LogId, @PlayerId, @CaptureBlocks OUTPUT
EXECUTE FlagEventSelectCountByPlayerIdLogId @LogId, @PlayerId, 'captured', @FlagsCaptured OUTPUT
EXECUTE FlagEventSelectCountByPlayerIdLogId @LogId, @PlayerId, 'picked up', @FlagsTouched OUTPUT
EXECUTE FlagEventSelectCountByPlayerIdLogId @LogId, @PlayerId, 'defended', @FlagsDefended OUTPUT
EXECUTE MedicChargeSelectCountByPlayerIdLogId @LogId, @PlayerId, @Ubers OUTPUT
EXECUTE DominationsSelectCountByPlayerIdLogId @LogId, @PlayerId, @Dominations OUTPUT
EXECUTE RevengesSelectCountByPlayerIdLogId @LogId, @PlayerId, @Revenges OUTPUT
EXECUTE CustomKillSelectCountByPlayerIdLogId @LogId, @PlayerId, 'backstab', @Backstabs OUTPUT
EXECUTE CustomKillSelectCountByPlayerIdLogId @LogId, @PlayerId, 'headshot', @Headshots OUTPUT



select @ReturnName as [PlayerName], 0 as [Points], @Kills as [Kills], @Assists as [Assists], @Deaths as [Deaths],
		@Destructions as [Destructions], @BuiltObjects as [BuiltObjects], @Captures as [Captures],
		@CaptureBlocks as [CaptureBlocks], @FlagsCaptured as [FlagsCaptured], @FlagsTouched as [FlagsTouched],
		@FlagsDefended as [FlagsDefended], @Ubers as [Ubers], @Dominations as [Dominations], @Revenges as [Revenges],
		0.0 as [KillDeathRatio], @Backstabs as [Backstabs], @Headshots as [Headshots], @PlayerId as [PlayerId]

END
GO